package com.aios.action.settings.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.aios.action.AbstractManagementAction;
import com.aios.entity.Controller;
import com.aios.entity.unit.ControllerType;
import com.aios.exception.ItemNotFoundException;
import com.aios.exception.NullReferenceAccessException;
import com.aios.service.ControllerService;

public abstract class AbstractControllerAction extends AbstractManagementAction {

	private static final long serialVersionUID = 1L;
	private static Logger logger = Logger.getLogger(AbstractControllerAction.class);
	
	protected Controller controller;
	protected Map<Integer,String> cameraType;
	
	@Qualifier("controllerService")
	@Autowired protected ControllerService controllerService;
	
	public Controller findById() {

		if (id != null) {
			try {
				return controllerService.findById(id);
			} catch (Exception e) {
				throw new ItemNotFoundException("Controller Id : " + id);
			}
		} else {
			// logger
			throw new NullReferenceAccessException("Id cannot be null");
		}
	}

	public Controller getController() {
		return controller;
	}

	public void setController(Controller controller) {
		this.controller = controller;
	}
	
	public void populateCameraType(Locale locale){
		//cameraType=new ArrayList<String>();
		//cameraType=ControllerType.getList(locale);
		cameraType= ControllerType.getMap(locale);
	}

	public Map<Integer, String> getCameraType() {
		return cameraType;
	}

	public void setCameraType(Map<Integer, String> cameraType) {
		this.cameraType = cameraType;
	}

	
	
	
}
